#include "elisa/elisa.h"
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <gaol/gaol>

#include "Modeler.h"

#ifdef ELISA_PERFORMER
#include "elisa_chrono.h"
#endif

using namespace std;
using namespace elisa;

class Bird : public Modeler
{
private:
	IntervalConstant v0;
	RealConstant g0;

	Model _model;

	RealVar alpha;
	RealVar z;
	RealVar y;

	RealConstraint c1;
	RealConstraint c2;

public:
	Bird()
		: v0(99.9, 100.1),
		  g0(10.0),
		  _model(),
		  alpha(elisa::Interval(elisa::Interval::Pi/8., elisa::Interval::Pi/7.), "alpha"),
		  z(elisa::Interval(0, 100), "z"),
		  y(elisa::Interval(0, 100), "y"),
		  c1(z == (-0.5*(g0) * (sqr(y)/(sqr(v0)*sqr(cos(alpha)))) 
			 + y*tan(alpha))),
		  c2(z == sin(y) + 10)
	{
	}

	elisa::Model & model()
	{
		_model = c1 && c2;
		return _model;
	}

	void print()
	{
		cout << '\t' << "z     ~ " << z.domain() << endl;
		cout << '\t' << "y     ~ " << y.domain() << endl;
		cout << '\t' << "alpha ~ " << alpha.domain() << endl;
	}

	RealVar & varX()
	{
		return z;
	}
	RealVar & varY()
	{
		return y;
	}
};
